package thread;

public class SyncAPIDemo1 {
    public static void main(String[] args) {
        StringBuilder b = new StringBuilder();
//        StringBuffer b = new StringBuffer();
        Thread t1 = new Thread(){
            public void run(){
                for (int i=0;i<1000;i++){
                    b.append("a");
                }
            }
        };
        Thread t2 = new Thread(){
            @Override
            public void run() {
                for (int i=0;i<1000;i++){
                    b.append("a");
                }
            }
        };

        t1.start();
        t2.start();

        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }


        System.out.println(b.length());
    }
}
